package com.dream21th.common;

import com.dream21th.common.utils.Dates;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

@Getter
@Setter
@ToString
public class ComReq<T> {


    private String requestNo;


    private String channelCode;


    private String productCode;


    private String requestTime;


    private String callBackUrl;


    private String source;


    private String version;


    private String sence;

    private T requestData;


    public ComReq<T> requestData(T t) {
        this.requestData = t;
        return this;
    }

    public ComReq<T> callbackUrl(String callbackUrl) {
        this.callBackUrl = callbackUrl;
        return this;
    }

    public ComReq<T> fromComReq(ComReq<?> comReq) {
        this.callBackUrl = comReq.getCallBackUrl();
        this.productCode = comReq.getProductCode();
        this.channelCode = comReq.getChannelCode();
        this.requestNo = comReq.getRequestNo();
        return this;
    }

    public ComReq<T> requestNo(String requestNo) {
        this.requestNo = requestNo;
        return this;
    }

    public ComReq<T> channelCode(String channelCode) {
        this.channelCode = channelCode;
        return this;
    }

    public ComReq<T> productCode(String productCode) {
        this.productCode = productCode;
        return this;
    }

    public ComReq<T> requestTime(String requestTime) {
        this.requestTime = requestTime;
        return this;
    }

    public ComReq<T> sence(String sence) {
        this.sence = sence;
        return this;
    }

    public ComReq<T> build() {
        this.version = "v1.0";
        this.source = "PH";
        this.requestTime = Dates.getyyyyMMddHHmmssCurDate();
        return this;
    }

}
